package com.chenl.provider.DEMOS.日志相关.全链路日志以及Spring线程池装饰器的使用.two;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

@Slf4j
@RestController
@RequestMapping("/logTest")
public class logTest {
    public static void main(String[] args) {

    }
    @GetMapping("/test")
    public void  test(){
        log.info("我来测试了");
        ExecutorService executorService = Executors.newSingleThreadExecutor();
        executorService.submit(new Runnable() {
            @Override
            public void run() {
                log.info("异步线程测试");
            }
        });
        executorService.shutdown();
        //-----------------------------
        ExecutorService executorService2 = Executors.newSingleThreadExecutor();
        executorService2.submit(new MyrunnableDecorate(new Runnable() {
            @Override
            public void run() {
                log.info("异步线程测试2");//经过包装之后，可以在异步线程中打印出来traceId
            }
        }));
        executorService2.shutdown();
    }
}
